#include "xxWidgetControl.h"



CString xx::WriteWidget(CDialogEx * Dlg, int ID, CString cstr) {
	Dlg->SetDlgItemText(ID, cstr);
	return cstr;
}

int xx::WriteWidget(CDialogEx * Dlg, int ID, int x) {
	Dlg->SetDlgItemInt(ID, x);
	return x;
}

float xx::WriteWidget(CDialogEx * Dlg, int ID, float x) {
	CString cstr;
	cstr.Format(L"%f", x);
	Dlg->SetDlgItemText(ID, cstr);
	return x;
}

double xx::WriteWidget(CDialogEx * Dlg, int ID, double x) {
	CString cstr;
	cstr.Format(L"%f", x);
	Dlg->SetDlgItemText(ID, cstr);
	return x;
}


CString xx::ReadWidget(CDialogEx * Dlg, int ID) {
	CString cstr;
	Dlg->GetDlgItemText(ID, cstr);
	return cstr;
}

int xx::ReadWidget(CDialogEx * Dlg, int ID, int DefaultValue) {
	CString cstr;
	Dlg->GetDlgItemText(ID, cstr);
	if (cstr == L"" || cstr == L"NULL") {
		return DefaultValue;
	}
	return _ttoi(cstr);
}

float xx::ReadWidget(CDialogEx * Dlg, int ID, float DefaultValue) {
	CString cstr;
	Dlg->GetDlgItemText(ID, cstr);
	if (cstr == L"" || cstr == L"NULL") {
		return DefaultValue;
	}
	return float(_ttof(cstr));
}

double xx::ReadWidget(CDialogEx * Dlg, int ID, double DefaultValue) {
	CString cstr;
	Dlg->GetDlgItemText(ID, cstr);
	if (cstr == L"" || cstr == L"NULL") {
		return DefaultValue;
	}
	return _ttof(cstr);
}

int xx::WriteCK(CDialogEx* Dlg, int ID, int CBvalue) {
	((CButton*)Dlg->GetDlgItem(ID))->SetCheck(CBvalue);
	return (CBvalue != 0);
}

int xx::ReadCK(CDialogEx* Dlg, int ID) {
	int x = ((CButton*)Dlg->GetDlgItem(ID))->GetCheck();
	return x;
}